package com.xiaohudie.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author xiao hu die
 * @Date 2022/2/21 19:01
 * @Version 1.0
 */
public class Test13 {
 public static void main(String[] args) throws ExecutionException, InterruptedException {
  FutureTask futureTask = new FutureTask(new Callable() {
   @Override
   public Object call() throws Exception {
    return 1 + 2;
   }
  });
  /**启动这个未来任务线程*/
  Thread thread = new Thread(futureTask);
  thread.start();
  Object o = futureTask.get();
  System.out.println(o);
 }
}
